<html>
<head><meta charset="utf-8"><title>channels vs concurrent hashmap · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/channels.20vs.20concurrent.20hashmap.html">channels vs concurrent hashmap</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="217813664"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/channels%20vs%20concurrent%20hashmap/near/217813664" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Maximilian Hristache <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/channels.20vs.20concurrent.20hashmap.html#217813664">(Nov 24 2020 at 21:07)</a>:</h4>
<p>Hi, is it better to use MPSC channels to send/share data from multiple threads to a main thread or a concurrent hashmap (e.g. dashmap) is better suited for that?</p>



<a name="217814080"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/channels%20vs%20concurrent%20hashmap/near/217814080" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/channels.20vs.20concurrent.20hashmap.html#217814080">(Nov 24 2020 at 21:11)</a>:</h4>
<p><span class="user-mention" data-user-id="363601">@Maximilian Hristache</span> It depends on your use case.</p>



<a name="217814101"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/channels%20vs%20concurrent%20hashmap/near/217814101" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/channels.20vs.20concurrent.20hashmap.html#217814101">(Nov 24 2020 at 21:11)</a>:</h4>
<p>And where your bottlenecks are.</p>



<a name="217814214"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/channels%20vs%20concurrent%20hashmap/near/217814214" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/channels.20vs.20concurrent.20hashmap.html#217814214">(Nov 24 2020 at 21:12)</a>:</h4>
<p>(Also, personally I'd recommend <code>flume</code> over the standard <code>mpsc</code> channels.)</p>



<a name="217814222"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/channels%20vs%20concurrent%20hashmap/near/217814222" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Maximilian Hristache <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/channels.20vs.20concurrent.20hashmap.html#217814222">(Nov 24 2020 at 21:12)</a>:</h4>
<p>I am creating a bunch of JSON Values from multiple threads and I want to send a copy of each of them to another thread that does some filtering, logging to stdout using slog and also updates some prometheus metrics</p>



<a name="217814280"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/channels%20vs%20concurrent%20hashmap/near/217814280" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/channels.20vs.20concurrent.20hashmap.html#217814280">(Nov 24 2020 at 21:13)</a>:</h4>
<p>Are the prometheus metrics the ones you were thinking of keeping in the dashmap?</p>



<a name="217814389"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/channels%20vs%20concurrent%20hashmap/near/217814389" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Maximilian Hristache <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/channels.20vs.20concurrent.20hashmap.html#217814389">(Nov 24 2020 at 21:14)</a>:</h4>
<p>was thinking to keep the entire json Value with some logic to clean up old entries after some time</p>



<a name="217814472"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/channels%20vs%20concurrent%20hashmap/near/217814472" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Maximilian Hristache <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/channels.20vs.20concurrent.20hashmap.html#217814472">(Nov 24 2020 at 21:15)</a>:</h4>
<p>is flume better than crossbeam::channel?</p>



<a name="217814842"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/channels%20vs%20concurrent%20hashmap/near/217814842" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Maximilian Hristache <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/channels.20vs.20concurrent.20hashmap.html#217814842">(Nov 24 2020 at 21:18)</a>:</h4>
<p>forgot to mention that I need to do some correlation between Values received from different threads so I will need to save the Values to a hashmap anyhow in the main thread</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>